import axios from "../utils/axios"

const getOrgan = async (_data: { limit: Number, page: Number, inOrganName: string,organId:number }) => {
    const data = await axios({
        url: '/organ_norm/findLike',
        method: 'post',
        data: _data
    })
    return data;
}

//体检机构全部
const getOrganId = async (organId: Number) => {
    const data = await axios({
        url: '/organ/findAll',
        method: 'get',
        params: {
            id: organId
        }
    })
    return data;
}
//指标映射渲染
const getTarget = async (nid: string,ncode:string) => {
    const data = await axios({
        url: '/norm/list',
        method: 'post',
        data: {
            nid: nid,
            ncode:ncode
        }
    })
    return data;
}

//指标映射-两个指标的id
const updateById = async (_data:{}) => {
    const data = await axios({
        url: '/organ_norm/updateByIds',
        method: 'post',
        data: _data
    })
    return data;
}


//编辑
const editOrgan = async (_data: {
    inCode: string;
    inHighPrompt:string;
    inLowPrompt: string;
    inId: number;
    inNormalPrompt: string;
    inOrganCeiling: string;
    inOrganFloor: string;
    inOrganName: string;
    inOrganUnit: string;
    organName: string
  }) => {
    const data = await axios({
        url: 'organ_norm/update',
        method: 'post',
        data: _data
    })
    return data;
}
//添加
const addOrgan = async (_data: {
    inOrganCeiling: string;
    inOrganFloor: string;
    inOrganName: string;
    inOrganUnit: string;
    organName: string;
    organId:number
  }) => {
    const data = await axios({
        url: 'organ_norm/add',
        method: 'post',
        data: _data
    })
    return data;
}
//删除
const delOrgan=async(inId:number)=>{
    const data=await axios({
         //url:'organ_norm/id=23',
         url:`organ_norm/id=${inId}`,
        method:'get',
    })
    return data
}
//批量删除
const delIdsOrgan=async(ids:number)=>{
    const data=await axios({
        url:'organ_norm/deleteByIds',
        method:'post',
        data:{
            ids:ids 
        }
    })
}
export {
    getOrgan,
    getOrganId,
    getTarget,
    updateById,
    editOrgan,
    addOrgan,
    delOrgan,
    delIdsOrgan
}